/********************************** (C) COPYRIGHT *******************************
* File Name          : module_config.h
* Author             : nx666
* Version            : V1.0.0
* Date               : 2023/06/12
* Description        : 定义配置.
*******************************************************************************/
#ifndef __MODULE_CONFIG_H
#define __MODULE_CONFIG_H

#ifdef __cplusplus
extern "C" {
#endif

//

#define         CHOSE_SECTOR       (0)

#define         CLARKE_CONVERT_N  (0.666666)            //等幅变换 N=2/3 , 等功率变换 N = sqrt(2/3)

//电机参数
#define         MOTOR_UDC         (11.4)                 //母线电压
#define         MOTOR_RS          (84.83 * 3.50)              //电机等效电阻 豪欧姆
#define         MOTOR_LS          (11.81 *100)                 //电机等效电感 uH
#define         MOTOR_RS1          (84.83 * 3.5)              //电机等效电阻 豪欧姆
#define         MOTOR_LS1          (11.81 *130)                 //电机等效电感 uH
#define         MOTOR_VB          (11.4)               //电机额定电压，母线电压
#define         MOTOR_IB          (9)                   //电机额定电流，电流环输出最大电流
#define         SMOPOS_TS         (0.001)              //滑膜观测器TS  单位s
#define         SMO_KSLF          (0.3)                 //滑膜观测器 低通滤波器增益
// #define         SMO_KSLIDE        (0.186)  
// #define         SMO_KSLIDE1        (0.126)
#define         SMO_KSLIDE        (3.386)  
#define         SMO_KSLIDE1        (3.326)
#define         SMO_E0            (1)
#define         SMO_FITER_WINDOW_SIZE (16)              // 滑膜观测器 滑动平均滤波窗口大小
#define         PLL_KSLF          (0.1)
#define         PLL_PI_DIV6       (15.7079)            //pi/2
#define         PLL_2MPY_PI       (6.28318)             //2*pi
#define         IQ8_2_PI          (1068)
#define         IQ8_1_PI          (804)
#define         UD_UQ_LIMIT       (2048)
#define         ID_IQ_LIMIT       (2048)
#define         OPEN_LOOP_OMEGA   (195)

//采样
#define         FOC_CALC_CYCLE         (125)               //foc 调节周期 单位：us
// #define         FOC_CALC_CYCLE          (200)
#define         FOC_SAMPLING_VREF_V     (3300)                // adc 参考电压 mv
#define         FOC_SAMPLING_V_ZERO_A   (1650)                // 电压0点 mv
#define         FOC_SAMPLING_V_ZERO_B   (1650)                // 电压0点 mv
#define         FOC_SAMPLING_V_ZERO_C   (1650)                // 电压0点 mv
#define         FOC_SAMPLING_ADC_ZERO  (2048)               //adc值0点
#define         FOC_SAMPLING_ADC_WIDTH (12)                //adc位宽
#define         FOC_SAMPLING_RS        (3)                 //采样电阻值 毫欧姆
#define         FOC_SAMPLING_CHIP_GAIN (20)                //电流采样芯片增益
#define         FOC_SAMPLING_FACTOR    (FOC_SAMPLING_RS * FOC_SAMPLING_CHIP_GAIN)
#define         FOC_SAMPLING_LPF_K    (0.4)               //低通滤波系数
#define         FOC_SAMPLING_MAX_I     (10000)             //最大电流 mA
#define         FOC_SAMPLING_ARRAY_LEN (6)                //每次采集 1 << FOC_SAMPLING_ARRAY_LEN个样本计算平均值作为采样值
#define         FOC_SAMPLING_FITER_CMP (2)
#define         FOC_SAMPLING_FITER_WINDOW_SIZE (8)

#ifdef __cplusplus
}
#endif

#endif /*__MODULE_CONFIG_H */